package com.hznu.jspFinal.service;

import com.hznu.jspFinal.dao.DepartmentMapper;
import com.hznu.jspFinal.entity.Department;
import com.hznu.jspFinal.myBeans.R;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * author:wp
 * time:19:24 2018/05/31
 */
@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Override
    public Department findById(Integer id)
    {
        return departmentMapper.selectByPrimaryKey(id);
    }
    @Override
    public int addOne(Department department)
    {
        return departmentMapper.insertSelective(department);
    }

    @Override
    public int update(Department department)
    {
        return departmentMapper.updateByPrimaryKeySelective(department);
    }

    @Override
    public int deleteById(Integer id)
    {
        return departmentMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Department findByName(String name)
    {
        return departmentMapper.selectByName(name);
    }

    @Override
    public List<Department> findBySchoolid(Integer schoolid)
    {
        return departmentMapper.selectBySchoolid(schoolid);
    }

}
